<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>无重复字符的最长子串</title>
    </head>
    <body>
        <div>给定一个字符串，请你找出其中不含有重复字符的最长子串的长度。</div>
        <pre  class="language-JavaScript">
            <code>
                /**
                * 方法一
                * @param {string} s
                * @return {number}
                */
            var lengthOfLongestSubstring1 = function(s) {
                let include = new Array();
                let length = 0;
                for(let i = 0; i < s.length; i ++) {
                    let index = include.indexOf(s[i]);

                    if(index !== -1) {
                        length = Math.max(include.length, length);
                        include.splice(0, index + 1);
                    } 
                    include.push(s[i]);
                }
                return Math.max(include.length, length);
            };
            </code>
        </pre>
    
        <script>
            /**
             * 方法一
            * @param {string} s
            * @return {number}
            */
            var lengthOfLongestSubstring1 = function(s) {
                let include = new Array();
                let length = 0;
                for(let i = 0; i < s.length; i ++) {
                    let index = include.indexOf(s[i]);

                    if(index !== -1) {
                        length = Math.max(include.length, length);
                        include.splice(0, index + 1);
                    } 
                    include.push(s[i]);
                }
                return Math.max(include.length, length);
            };
        </script>
    </body>
</html>